﻿@model IEnumerable<StoreDemo.Domain.Entities.Product>

@{
    ViewBag.Title = "Products";
}

<h2>Products</h2>

@if (Model.Any())
{
    <p>@Html.ActionLink("Add a new Product", "Create")</p>
    <table>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Price</th>
            <th></th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>@Html.DisplayFor(modelItem => item.Name)</td>
                <td>@Html.DisplayFor(modelItem => item.Description)</td>
                <td>@Html.DisplayFor(modelItem => item.Price)</td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { productId = item.ProductId }) |
                    @Html.ActionLink("Delete", "Delete", new { idOfProductToBeDeleted = item.ProductId })
                </td>
            </tr>
        }
    </table>
}
else
{
    <p>You do not currently have any products in the system. Would you like to @Html.ActionLink("Create", "Create") a new one?</p>
}